#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]) {
    ifstream in;
    ofstream out;
    int i, j, frames, particles;
    float radius;
    float x, y, z;
    stringstream ss;
    string str;

    if (argc != 2) {
        cerr << "usage: split [file]\n";
        exit(EXIT_FAILURE);
    }

    in.open((char *)argv[1]);

    in >> frames >> particles >> radius;

    for (i = 0; i < frames; i++) {
        ss << i;
        str = ss.str();
        out.open(string("sim" + str + ".sim").c_str(), ofstream::out);

        out << "1 " << particles << " " << radius << endl;
        for (j = 0; j < particles; j++) {
            in >> x >> y >> z;
            out << x << " " << y << " " << z << endl;
        }
        out.close();
        ss.str("");
    }

    in.close();
}
